package com.compass.doctor.ui.chat.viewholder;

import android.view.LayoutInflater;
import android.view.View;

import androidx.annotation.NonNull;

import com.compass.doctor.R;
import com.compass.doctor.databinding.ChatMessageExamineViewHolderBinding;
import com.compass.doctor.databinding.ChatMessagePrescriptionViewHolderBinding;
import com.compass.doctor.ui.chat.attachment.ExamineAttachment;
import com.compass.doctor.ui.chat.attachment.InquiryAttachment;
import com.compass.framework.utils.BigDecimalUtils;
import com.netease.yunxin.kit.chatkit.ui.common.MessageHelper;
import com.netease.yunxin.kit.chatkit.ui.databinding.ChatBaseMessageViewHolderBinding;
import com.netease.yunxin.kit.chatkit.ui.fun.view.message.viewholder.FunChatBaseMessageViewHolder;
import com.netease.yunxin.kit.chatkit.ui.model.ChatMessageBean;

/**
 * Description： 检验检查ViewHolder
 * Date:2024/1/22 17:20
 */
public class ExamineViewHolder extends FunChatBaseMessageViewHolder {
    public static final String TAG = "InquiryViewHolder";
    ChatMessageExamineViewHolderBinding binding;
    ExamineAttachment attachment;

    public ExamineViewHolder(@NonNull ChatBaseMessageViewHolderBinding parent, int viewType) {
        super(parent, viewType);
    }

    @Override
    protected void addViewToMessageContainer() {
        binding = ChatMessageExamineViewHolderBinding.inflate(LayoutInflater.from(parent.getContext()), getMessageContainer(), true);

    }


    @Override
    public void bindData(ChatMessageBean message, ChatMessageBean lastMessage) {
        super.bindData(message, lastMessage);
        currentMessage = message;
        attachment = (ExamineAttachment) message.getMessageData().getMessage().getAttachment();
        if (attachment == null) {
            return;
        }
        //设置ViewHolder展示UI的内容
//        binding.patientName.setText(attachment.getPatientName());

        binding.tvTypeName.setText("检验检查");
        binding.describe.setText("诊断："+attachment.getDiagnosisName());
        binding.tvDepartments.setVisibility(View.VISIBLE);
        binding.tvPriceName.setVisibility(View.VISIBLE);
        binding.tvPrice.setVisibility(View.VISIBLE);
        binding.tvDepartments.setText("科室："+attachment.getDepartmentName());
        binding.tvInpatientWard.setText(attachment.getInspectionName());
        binding.tvPrice.setText("￥"+BigDecimalUtils.divide(attachment.getPrice()));
    }



    @Override
    protected void onMessageBackgroundConfig(ChatMessageBean messageBean) {
        super.onMessageBackgroundConfig(messageBean);
        boolean isReceivedMsg = MessageHelper.isReceivedMessage(messageBean);
        View firstChild = baseViewBinding.messageContainer.getChildAt(0);
        if (isReceivedMsg) {
            firstChild.setBackgroundResource(R.drawable.bg_custom_message);
        } else {
            firstChild.setBackgroundResource(R.drawable.bg_custom_message_out);
        }
    }
}
